//
//  STOSRViewModel.swift
//  iPhone
//
//  Created by Toj on 3/7/24.
//

import Foundation

class STOSRViewModel: NSObject {
    
    private(set) lazy var classSections: [VCSectionModel] = []
}

extension STOSRViewModel {
    
    func setupSections(complete: @escaping ()->Void) {
        DispatchQueue.global(qos: .background).async {
            var sections = [VCSectionModel]()
            var sectionModel = VCSectionModel()
            
            sectionModel = self.setupViewCellModels()
            sections.append(sectionModel)
            
            sectionModel = self.setupLabelCellModels()
            sections.append(sectionModel)

            sectionModel = self.setupButtonCellModels()
            sections.append(sectionModel)

            sectionModel = self.setupImageCellModels()
            sections.append(sectionModel)
            
            DispatchQueue.main.async {
                self.classSections = sections
                complete()
            }
        }
    }
}

private extension STOSRViewModel {
    
    func setupSection() -> VCSectionModel {
        let section = VCSectionModel()
        section.headerSize = CGSize(width: .sr_width, height: 44)
        section.footerSize = .def_cipher
        return section
    }
}

// MARK: - 数据
private extension STOSRViewModel {
    
    // MARK: UIView
    func setupViewCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STOSRViewCornerViewController.cm_objectName
        cellModel.des = "UIView 开启光栅化 shouldRasterize = true"
        cellModels.append(cellModel)
        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRViewCornerViewController.cm_objectName
//        cellModel.des = "UIView 抗锯齿 edge antialiasing"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRViewCornerViewController.cm_objectName
//        cellModel.des = "UIView 透明组 group opacity"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRViewCornerViewController.cm_objectName
//        cellModel.des = "UIView 圆角 circleRadius"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRViewCornerViewController.cm_objectName
//        cellModel.des = "UIView 阴影 shadows"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRViewCornerViewController.cm_objectName
//        cellModel.des = "UIView 遮罩渐变 masks"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRViewCornerViewController.cm_objectName
//        cellModel.des = "UIView 遮罩其他 masks"
//        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "UIView"
        section.cellModels = cellModels
        
        return section
    }
    
    // MARK: UILabel
    func setupLabelCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STOSRLabelCornerViewController.cm_objectName
        cellModel.des = "UILabel 开启光栅化 shouldRasterize = true"
        cellModels.append(cellModel)
        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRLabelCornerViewController.cm_objectName
//        cellModel.des = "UILabel 抗锯齿 edge antialiasing"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRLabelCornerViewController.cm_objectName
//        cellModel.des = "UILabel 透明组 group opacity"
//        cellModels.append(cellModel)
//        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRLabelCornerViewController.cm_objectName
//        cellModel.des = "UILabel 圆角 circleRadius"
//        cellModels.append(cellModel)
//        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRLabelCornerViewController.cm_objectName
//        cellModel.des = "UILabel 阴影 shadows"
//        cellModels.append(cellModel)
//        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRLabelCornerViewController.cm_objectName
//        cellModel.des = "UILabel 遮罩渐变 masks"
//        cellModels.append(cellModel)
//        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRLabelCornerViewController.cm_objectName
//        cellModel.des = "UILabel 遮罩其他 masks"
//        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "UILabel"
        section.cellModels = cellModels
        
        return section
    }
    
    // MARK: UIButton
    func setupButtonCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STOSRButtonCornerViewController.cm_objectName
        cellModel.des = "UIButton 开启光栅化 shouldRasterize = true"
        cellModels.append(cellModel)
        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRButtonCornerViewController.cm_objectName
//        cellModel.des = "UIButton 抗锯齿 edge antialiasing"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRButtonCornerViewController.cm_objectName
//        cellModel.des = "UIButton 透明组 group opacity"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRButtonCornerViewController.cm_objectName
//        cellModel.des = "UIButton 圆角 circleRadius"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRButtonCornerViewController.cm_objectName
//        cellModel.des = "UIButton 阴影 shadows"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRButtonCornerViewController.cm_objectName
//        cellModel.des = "UIButton 遮罩渐变 masks"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRButtonCornerViewController.cm_objectName
//        cellModel.des = "UIButton 遮罩其他 masks"
//        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "UIButton"
        section.cellModels = cellModels
        
        return section
    }
    
    // MARK: UIImageView
    func setupImageCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STOSRImageViewCornerController.cm_objectName
        cellModel.des = "UIImageView 开启光栅化 shouldRasterize = true"
        cellModels.append(cellModel)
        
//        cellModel = VCCellModel()
//        cellModel.name = STOSRImageViewCornerController.cm_objectName
//        cellModel.des = "UIImageView 抗锯齿 edge antialiasing"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRImageViewCornerController.cm_objectName
//        cellModel.des = "UIImageView 透明组 group opacity"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRImageViewCornerController.cm_objectName
//        cellModel.des = "UIImageView 圆角 circleRadius"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRImageViewCornerController.cm_objectName
//        cellModel.des = "UIImageView 阴影 shadows"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRImageViewCornerController.cm_objectName
//        cellModel.des = "UIImageView 遮罩渐变 masks"
//        cellModels.append(cellModel)
//
//        cellModel = VCCellModel()
//        cellModel.name = STOSRImageViewCornerController.cm_objectName
//        cellModel.des = "UIImageView 遮罩其他 masks"
//        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "UIImageView"
        section.cellModels = cellModels
        
        return section
    }
}
